// Copyright (c) 2021 Tencent. All rights reserved.
// Author: tatemin

import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:tencent_calls_engine/tuicall_observer.dart';

import 'tuicall_engine_method_channel.dart';

abstract class TUICallEnginePlatform extends PlatformInterface {
  /// Constructs a TuicallEnginePlatform.
  TUICallEnginePlatform() : super(token: _token);

  static final Object _token = Object();

  static TUICallEnginePlatform _instance = MethodChannelTUICallEngine();

  /// The default instance of [TUICallEnginePlatform] to use.
  ///
  /// Defaults to [MethodChannelTUICallEngine].
  static TUICallEnginePlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [TUICallEnginePlatform] when
  /// they register themselves.
  static set instance(TUICallEnginePlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<void> addObserver(TUICallObserver observer) async {
    await _instance.addObserver(observer);
  }

  Future<void> removeObserver(TUICallObserver observer) async {
    await _instance.removeObserver(observer);
  }
}
